﻿using System;
using CollegeSim.Domain.Entities;
using Microsoft.VisualStudio.TestTools.UnitTesting;

namespace CollegeSim.Domain.Test.Entities
{
    // Author: Ryan Redburn
    // Project: CollegeSim
    // Date: 5/13/2014

    [TestClass]
    public class SchoolYearTest
    {
        #region [ SchoolYearID ]

        [TestMethod]
        public void SemesterID_DefaultValue_EqualsExpected()
        {
            // Arrange
            var schoolYear = new SchoolYear();

            // Assert
            Assert.AreEqual(0, schoolYear.SchoolYearID);
        }

        #endregion

        #region [ Start ]

        [TestMethod]
        public void SchoolYearStart_AfterEnd_ArgumentOutOfRangeExecption()
        {
            // Arrange
            var assert = false;
            var schoolYear = new SchoolYear
            {
                Start = new DateTime(2014, 8, 29),
                End = new DateTime(2015, 5, 3)
            };


            try
            {
                // Act
                schoolYear.Start = new DateTime(2015, 8, 29);
            }
            catch (ArgumentOutOfRangeException)
            {
                assert = true;
            }
            finally
            {
                // Assert
                Assert.IsTrue(assert);
            }
        }

        #endregion

        #region [ End ]

        [TestMethod]
        public void SchoolYearEnd_BeforeStart_ArgumentOutOfRangeException()
        {
            // Arrange
            var assert = false;
            var schoolYear = new SchoolYear
            {
                Start = new DateTime(2014, 8, 29),
                End = new DateTime(2015, 5, 3)
            };

            try
            {
                // Act
                schoolYear.End = new DateTime(2014, 5, 3);
            }
            catch (ArgumentOutOfRangeException)
            {
                assert = true;
            }
            finally
            {
                // Assert
                Assert.IsTrue(assert);
            }
        }

        #endregion
    }
}
